package com.gozap.base;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;


public class FileClock2MulType {
	
	private List<Integer> days=new ArrayList<Integer>();
	
	public static void main(String[] args) {

		FileClock2MulType type=new FileClock2MulType();
		FileClock2MulType.SetClock clock = type.new SetClock();
		Thread thread=new Thread(clock);
		thread.start();
	}
	
	public SetClock getSetClock(){
		return new SetClock();
	}
	public void setDay(){
		days.add(Calendar.MONDAY);
		days.add(Calendar.THURSDAY);
		days.add(Calendar.WEDNESDAY);
		days.add(Calendar.TUESDAY);
		days.add(Calendar.FRIDAY);
		days.add(Calendar.SATURDAY);
		days.add(Calendar.SUNDAY);
	}
	class SetClock implements Runnable{
		private String time="16:11";
		public void run() {
			
				int day=Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
				setDay();
				while(true){
					System.out.println("in");
					if(inDay(day, days)){
						Date date=Calendar.getInstance().getTime();
						String now=convertDateToString(date);
						System.out.println(now);
						if( now.endsWith(time) ){
							System.out.println("hhh");
							execute();
						}
					}
					try {
						Thread.sleep(30000);
					} catch (Exception e) {
					}
					
				}
		}
		public String convertDateToString(Date date){
			String result="";
			SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm");
			result=format.format(date);
			return result;
		}
		public void execute(){
			try {
				String command="cmd /c start E:\\联系人导出\\蜡笔工具箱_导入联系人.jpg";
				//Process process=
				Runtime.getRuntime().exec(command);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}

		public boolean inDay(int day,List<Integer> list){
			for(Integer i:list){
				if(i==day){
					return true;
				}
			}
			return false;
		}
		
		
	}
}
